package com.quick.framework.config;

import com.quick.framework.filter.RequestLoggingFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 过滤器配置
 *
 * @Author: Administrator
 * @Date: 2023/7/25
 */

public class FilterConfig {
    @Bean
    public FilterRegistrationBean<RequestLoggingFilter> loggingFilter() {
        FilterRegistrationBean<RequestLoggingFilter> registrationBean = new FilterRegistrationBean<>();
        // 创建并注册自定义过滤器
        RequestLoggingFilter filter = new RequestLoggingFilter();
        registrationBean.setFilter(filter);
        // 设置过滤器的URL匹配模式
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}
